<template>
  <section class="oa-form__table">
    <h5>{{ approve.name }}</h5>
    <table cellpadding="0" cellspacing="0">
      <tr v-if="$route.query.from != 'new'">
        <td>事务编号</td>
        <td>
          {{ approve.name }}
          <span v-if="approve && approve.code">{{ approve.code }}</span>
        </td>
      </tr>
      <tr>
        <td>流程名称</td>
        <td>
          <span v-if="$route.query.from == 'new'">新建{{ approve.name }}</span>
          <span v-else>
            {{ approve.approve_name }}
          </span>
        </td>
      </tr>
      <tr>
        <td>申请事由</td>
        <td :title="reason"><el-input placeholder="申请事由" type="textarea" v-model="reason" :disabled="$route.query.from != 'new'"/></td>
      </tr>
    </table>
    <h3 class="oa-form__table-title">
      <span v-if="$route.query.from === 'new'">{{ approve.name }}</span>
      <span v-else>
        {{ approve.approve_name }}
      </span>
    </h3>
    <table class="achievement__tab" border="1">
      <tr class="border_0">
        <td>考核周期:</td>
        <td>
          <el-date-picker
            value-format="yyyy-MM-dd"
            type="date"
            v-model="applyTime"
            :disabled="$route.query.from !== 'new'"
            placeholder="考核周期">
          </el-date-picker>
        </td>
        <td>部门:</td>
        <td width="400">
          <el-select v-model="department" :disabled="$route.query.from != 'new'" placeholder="请选择">
            <el-option
              v-for="item in departments"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </td>
        <td>姓名:</td>
        <td>
          <el-select v-model="value" style="width:60%" :disabled="$route.query.from != 'new'" placeholder="请选择"  @change="selectStaff($event)">
            <el-option
              v-for="item in staff"
              :key="item.value"
              :label="item.label"
              :value="item">
            </el-option>
          </el-select>
        </td>
        <td>岗位:<span style="display:inline-block;width:100px;padding-left:10px;"><el-input v-model="gangwei" :disabled="$route.query.from !== 'new'" placeholder="岗位"/></span></td>
      </tr>
      <tr>
        <td class="_name">考核指标</td>
        <td class="_name">指标定义</td>
        <td class="_name">权重</td>
        <td class="_name">评分说明</td>
        <td class="_name">数据来源</td>
        <td class="_name">自评</td>
        <td class="_name">评估得分</td>
        <!-- <td class="_name">扣分事项说明</td> -->
      </tr>
      <tr>
         <td rowspan="6">财务</td>
         <td>会计核算</td>
         <td>20%</td>
         <td>及时处理公司账务，常规业务发生或单据到达手上不超过24小时处理完毕确保账务完整；保证会计报表、纳税申报准确无误；保证档案完整（超时1次扣2分，出错1次扣5分）</td>
         <td>直属上级</td>
         <td><el-input v-model="obj.a273" :disabled="obj.a273Flag" /></td>
         <td><el-input v-model="obj.a283" :disabled="obj.a283Flag" /></td>
      </tr>
      <tr>
         <td>采购复核</td>
         <td>15%</td>
         <td>认真完成采购供应商报价复核工作，确保采购质量与成本最优（出错1次扣5分）</td>
         <td>直属上级</td>
         <td><el-input v-model="obj.a274" :disabled="obj.a274Flag" /></td>
         <td><el-input v-model="obj.a284" :disabled="obj.a284Flag" /></td>
      </tr>
      <tr>
         <td>费用复核</td>
         <td>10%</td>
         <td>当日收到单据当日复核完毕，确保按制度执行复核，保证费用真实、可信（超时1次扣2分，出错1次扣5分）</td>
         <td>直属上级</td>
         <td><el-input v-model="obj.a275" :disabled="obj.a275Flag" /></td>
         <td><el-input v-model="obj.a285" :disabled="obj.a285Flag" /></td>
      </tr>
      <tr>
         <td>成本费用控制</td>
         <td>10%</td>
         <td>成本费用控制在每月预算范围内（90%≤R&lt;95%加2分，90%&lt;R≤85%加4分，R&lt;85%加6分，100%&lt;R≤105%扣2分，105%&lt;R扣4分）</td>
         <td>直属上级</td>
         <td><el-input v-model="obj.a276" :disabled="obj.a276Flag" /></td>
         <td><el-input v-model="obj.a286" :disabled="obj.a286Flag" /></td>
      </tr>
      <tr>
         <td>系统流程</td>
         <td>10%</td>
         <td>常规业务发生当天需完成OA事项审核（超时1次扣2分，出错1次扣5分）</td>
         <td>直属上级</td>
         <td><el-input v-model="obj.a277" :disabled="obj.a277Flag" /></td>
         <td><el-input v-model="obj.a287" :disabled="obj.a287Flag" /></td>
      </tr>
      <tr>
         <td>供应商对账</td>
         <td>15%</td>
         <td>每月10日前提供供应商未附发票名单；负责与各部门对接外部对账单核对（超时1次扣2分，出错1次扣5分）</td>
         <td>工程部</td>
         <td><el-input v-model="obj.a278" :disabled="obj.a278Flag" /></td>
         <td>
           <el-input v-model="obj.a288" :disabled="obj.a288Flag" />
           <!-- <div>
            工程部<el-input v-model="obj.a791" :disabled="obj.a791Flag" />
           </div>
           <div>
             外联部<el-input v-model="obj.a792" :disabled="obj.a792Flag" />
           </div>
           <div>
             平均分<el-input v-model="b1" disabled/>
           </div> -->
         </td>
      </tr>
       <tr>
         <td>数据整理</td>
         <td>内部数据整理</td>
         <td>10%</td>
         <td>对公司制度及公司文化的理解和执行（包括根据公司整体规划制定个人业务计划，合理安排个人各项工作时间，遵守公司各项制度等）</td>
         <td>直属上级</td>
         <td><el-input v-model="obj.a279" :disabled="obj.a279Flag" /></td>
         <td><el-input v-model="obj.a289" :disabled="obj.a289Flag" /></td>
      </tr>
      <tr>
         <td>公司制度执行</td>
         <td>遵守公司制度</td>
         <td>10%</td>
         <td>对公司制度及公司文化的理解和执行（包括根据公司整体规划制定个人业务计划，合理安排个人各项工作时间，遵守公司各项制度等）</td>
         <td>行政部</td>
         <td><el-input v-model="obj.a280" :disabled="obj.a280Flag" /></td>
         <td><el-input v-model="obj.a290" :disabled="obj.a290Flag" /></td>
      </tr>
      <tr>
        <td rowspan="2">加分项</td>
        <td>增量工作内容</td>
        <td>&nbsp;</td>
        <td>超出岗位职责范围、领导交办较为繁杂的事务、工作表现卓越等</td>
        <td>总经理</td>
        <td><el-input v-model="obj.a281" :disabled="obj.a281Flag" /></td>
        <td><el-input v-model="obj.a291" :disabled="obj.a291Flag" /></td>
      </tr>
      <tr>
        <td>对公司的建议</td>
        <td>&nbsp;</td>
        <td>对市场拓展、业务销售、内部管理等建设性意见</td>
        <td>总经理</td>
        <td><el-input v-model="obj.a282" :disabled="obj.a282Flag" /></td>
        <td><el-input v-model="obj.a292" :disabled="obj.a292Flag" /></td>
      </tr>
      <tr>
        <td colspan="5"></td>
        <td>自评:{{myScore}}</td>
        <td>综合考核率:{{otherScore}}</td>
      </tr>
    </table>
    <history :process="process"></history>
    <files></files>
  </section>
</template>
<script>
import mixin from '@/mixins/index.js'
import history from '../service/components/process'
import files from '../service/components/files'
import { sum } from '@/utils/domUtils.js'
// import { save, info, getAutoKey } from '@/api/oa/index.js'
const obj = {}
for (let i = 272; i <= 292; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
for (let i = 291; i <= 292; i++) {
  obj[`a${i}`] = ''
  obj[`a${i}Flag`] = true
}
export default {
  mixins: [mixin],
  data () {
    return {
      reason: '',
      truename: '',
      department: '',
      flag: false,
      value: '',
      obj: JSON.parse(JSON.stringify(obj)),
      applyTime: '',
      gangwei: '',
      file_paths: [],
      file_names: [],
      field_ids: [],
      field_vals: [],
      autoField: []
    }
  },
  components: { history, files },
  props: ['curDepartment', 'userInfo', 'approve', 'staff', 'addDofield', 'departments', 'process'],
  computed: {
    uploadArr () {
      return this.$store.state.uploadArr
    },
    // b1 () {
    //   const num = parseFloat((Number(this.obj.a791) + Number(this.obj.a792)) / 2).toFixed(2)
    //   return num
    // },
    myScore () {
      const result = []
      for (let i = 273; i <= 282; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      return sum(result)
    },
    otherScore () {
      const result = []
      for (let i = 283; i <= 290; i++) {
        if (this.obj[`a${i}`]) {
          result.push(this.obj[`a${i}`])
        }
      }
      result.push(this.obj.a291)
      result.push(this.obj.a292)
      return sum(result)
    }
  },
  mounted () {
    this.$nextTick(() => {
      this.obj = JSON.parse(JSON.stringify(obj))
      if (this.$route.query.from === 'new') {
        this.disabled = true
      } else {
        this.infoFunc()
      }
    })
  },
  methods: {
  }
}
</script>
